package bonecp.bonecp_src_read;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import com.jolbox.bonecp.CustomThreadFactory;

public class TestExecutors {

	/**
	 * @param args
	 * @throws ExecutionException 
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		// TODO Auto-generated method stub
		ScheduledExecutorService scheduledExecutorService = Executors
				.newScheduledThreadPool(2, new CustomThreadFactory(
						"BoneCP-keep-alive-scheduler" + "", true));
		
/*		Future<String> result = scheduledExecutorService.submit(new Callable<String>() {
			public String call() throws Exception {
				Thread.sleep(10000);
				return "hello";
			}
		});
		System.out.println(result.get());*/
		
		
		ScheduledFuture<String> scheduledFuture = scheduledExecutorService.schedule(new Callable<String>() {
			public String call() throws Exception {
				return "111";
			}
		}, 10, TimeUnit.SECONDS);
		
		System.out.println(scheduledFuture.get());
	}

}
